
local function add_shop_iocn(name,art,x,y,w,h)
    local icon = class.button.create(art,x,y,w,h)
    local ani = class.panel.create(art,(1920-icon.w)/2,650,w,h)
    icon.ani = ani
    icon.title = icon:add_text(name,-10,icon.h,icon.w+20,20,10,5)
    icon:child_builder {
        parent = icon,
        type = 'model',
        model = [[UI\Feedback\Autocast\UI-ModalButtonOn.mdl]],
        x = 4,
        y = 2,
        scales = {icon.w / 94,icon.h / 70},
        show_flag = true,
    }

    --动画结束显示按钮
    function ani:move_animation_finish()
        ani:hide()
        icon:show()
    end

    --点击按钮选择商店
    function icon:on_button_clicked()
        icon:hide()
        if icon.unit then
            jass.ClearSelection()
            jass.SelectUnit(icon.unit.handle, true)
        end
    end
    ani:hide()
    icon:hide()
    return icon
end

local ui1 = add_shop_iocn('神秘商人',[[ReplaceableTextures\CommandButtons\BTNAcolyte.blp]],1250,750,64,64)
local ui2 = add_shop_iocn('限时挑战',[[ReplaceableTextures\CommandButtons\BTNAcolyte.blp]],1250 + 70,750,64,64)


ac.game:event 'UI-神秘商店刷新'(function(_,player,unit)
    if player:is_self()==false then
        return
    end
    local icon1 = ui1.ani
    icon1:show()
    icon1:set_real_position((1920-icon1.w)/2,650)
    ac.wait(500,function()
        icon1:move_animation({ui1.x,ui1.y},1.5,'线性')
    end)
    ui1:hide()
    ui1.unit = unit
    ui1.title:set_text(unit:get_name())
end)

ac.game:event 'UI-限时挑战刷新'(function(_,player,unit)
    if player:is_self()==false then
        return
    end
    local icon1 = ui2.ani
    icon1:show()
    icon1:set_real_position((1920-icon1.w)/2,650)
    ac.wait(500,function()
        icon1:move_animation({ui2.x,ui2.y},1.5,'线性')
    end)
    ui2:hide()
    ui2.unit = unit
    ui2.title:set_text(unit:get_name())
end)